<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo02选择器</title>
<!--内部样式-->
    <style>
        /*1.id选择器*/
        #d1{
            width: 100px;
            height: 100px;
            background-color: red;
        }
        /*2.class选择器*/
        .error{
            color: yellow;
        }
        .success{
            color: green;
        }
        .msg{
            font-size: 15px;
            background-color: red;
        }
        /*3.并列选择器*/
        #d1:hover{
            background-color: yellow;
        }
        /*4.群组选择器：用逗号隔开*/
        #d1,h4,.error{
            border: 3px solid darkmagenta;
        }
        /*5.伪类选择器*/
        a:link{
            color: darkgray;
        }
        a:visited{
            color: greenyellow;
        }
        a:hover{
            color: blue;
        }
        a:active{
            color: black;
        }
        /*6.属性选择器*/
        input[type="text"]{
            width: 200px;
            height: 30px;
        }
        input[name="uname"]{
            background-color: pink;
        }
        /*7.后代选择器*/
        #d2 span{
            color: red;
        }
        /*8.子代选择器*/
        #d2>div>p>span{
            color: lime;
        }

    </style>
</head>
<body>
<div id="d1">我是div</div>
<div>我是div</div>
<p>我是段落</p>
<h4>我是标题</h4>
<h4>我是标题</h4>
<hr>
<span class="error msg">用户名不能为空</span>
<span class="error msg">密码必须在6~12位之间</span>
<span class="success msg">手机号格式正确</span>
<span class="success msg">邮箱格式正确</span>
<hr>
<a href="https://www.baidu.com">超链接1</a>
<a href="abc">超链接2</a>
<hr>
姓名：<input type="text" name="uname">
昵称：<input type="text" name="nickname">
<select name="uname">
    <option value="1">666</option>
    <option value="2">777</option>
</select>
<hr>
<div id="d2">
    <span>111</span>
    <div>
        <span>222</span>
        <p>测试文字</p>
        <p>我是<span>333</span>段落</p>
    </div>
    <span>444</span>
</div>
</body>
</html>